Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
The array-uniq npm package is a simple and efficient utility for removing duplicate values from an array. It is designed to work with arrays containing primitive values such as strings, numbers, and booleans.
Removing duplicates from an array
This feature allows you to pass an array to the array-uniq function, which then returns a new array with all duplicate values removed. It works with numbers, strings, and booleans.
const arrayUniq = require('array-uniq');
const uniqueArray = arrayUniq([1, 1, 2, 3, 3]);
console.log(uniqueArray); // Output: [1, 2, 3]
lodash.uniq is part of the Lodash library, which provides a more comprehensive set of tools for working with arrays and objects. Unlike array-uniq, lodash.uniq supports arrays of objects and uses a custom comparator for uniqueness, which makes it more flexible but slightly slower for simple cases.
The uniq package offers similar functionality to array-uniq but includes additional features such as the ability to specify a custom iterator function to determine uniqueness. This can be useful for more complex comparison logic but adds overhead for simple use cases.
Create an array without duplicates
It's already pretty fast, but will be much faster when Set becomes available in V8 (especially with large arrays).
$ npm install --save array-uniq
var arrayUniq = require('array-uniq');
arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
MIT © Sindre Sorhus
FAQs
Create an array without duplicates
The npm package array-uniq receives a total of 3,661,145 weekly downloads. As such, array-uniq popularity was classified as popular.
We found that array-uniq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.